1. [Field of the Invention]
The present invention relates to an image processing apparatus for converting input image data into black/white binary image data and, a storage medium that stores a program associated with the apparatus.
2. [Description of the Related Art]
Binarization for converting a halftone image into a black/white binary image is used not only in processing of image data (e.g., texture source images in game machines or the like) but also in every field of image signal processing such as facsimile, OCR (optical character reader), medical image processing, visual robot, and the like. As a conventionally popular binarization method, a pseudo halftone display method based on so-called xe2x80x9corderedxe2x80x9d dithering, which superposes random numbers or pseudo random numbers (periodic random numbers) on a halftone image, and then A/D (analog/digital)-converts the halftone image, is known. As a method of giving random numbers or pseudo random numbers used, a Bayer pattern is preferably used.
FIG. 4A shows the principle of binarization based on xe2x80x9corderedxe2x80x9d dithering. FIG. 4B shows an example of a halftone image to be input to the binarization shown in FIG. 4A. A halftone image 420 shown in FIG. 4B consists of a set of 16(=4xc3x974) pixels (dots) 421, 422, . . . The numeral in the box of each pixel represents the gradation value of that pixel. For example, xe2x80x9c8xe2x80x9d is described in the box of the pixel 421, and xe2x80x9c7xe2x80x9d is described in the box of the pixel 422. These values respectively represent the gradation values of the corresponding pixels. In this case, the gradation level of each pixel is expressed by a numerical value ranging from 0 to 15 (i.e., 16 gradation levels).
In the binarization shown in FIG. 4A, when the halftone image 420 is input, a pseudo random number generator generates a pseudo random number (Bayer) pattern having 16(=4xc3x974) elements, and a subtracter 402 subtracts the corresponding element values of a pseudo random number pattern 401 from the gradation values of the individual pixels of the halftone image 420. For example, a random number xe2x80x9c0xe2x80x9d of an element 411 in the pseudo random number pattern 401 is subtracted from the gradation value xe2x80x9c8xe2x80x9d of the pixel 421 in the halftone image 420, and subtractions between the corresponding pixels and elements are similarly done. A discrimination circuit 403 outputs a dither image as a result of binarizing an element equal to or larger than 0 (or an element that exceeds 0) to 1 (means white) and an element that does not exceed 0 (or an element equal to or smaller than 0) to 0 (means black) in the subtraction results from the subtracter 402. In this case, 1 indicates white, and 0 black. But 1 may indicate black, and 0 white. The same applies to the embodiment of the present invention to be described later.
In the description of FIG. 4A, binarization is done by the subtracter 402 and discrimination circuit 403. To summarize, this processing compares the gradation values of the individual pixels in the halftone image 420 with the element values (to be referred to as threshold values hereinafter) in the pseudo random number pattern 401, and sets 1 (white) for a pixel at which the gradation value is equal to or larger than the threshold value) or 0 (black) for a pixel at which the gradation value does not exceed (or is equal to or smaller than) the threshold value. Such binarization may be realized by hardware or implemented by software.
When an input halftone image is large, it is broken up into ranges of 16 pixels(=4xc3x974), as shown in FIG. 4C, and individual ranges 431, 432, . . . are binarized by the aforementioned method to obtain a final dither image. In this case, two-dimensional blocks each consisting of 16(=4xc3x974) pixels (i.e., the order of pattern=4) are used as units.
Alternatively, two-dimensional blocks having other sizes, e.g., 64(=8xc3x978) pixels (the order of pattern=8), 256(=16xc3x9716) pixels (the order of pattern=16), and the like may be used as processing units.
FIG. 5A shows recurrence formulas used for generating the pseudo random number pattern used in the aforementioned binarization, i.e., a Bayer pattern. For example, if n=2 in FIG. 5A, a pattern of xe2x80x9cD4xe2x80x9d (the order of pattern=4) (i.e., the pseudo random number pattern 401 shown in FIG. 4A) is obtained. In normal use, since the number of gradation levels of an input halftone image to be binarized is 256 (a gradation value ranges from 0 to 255) expressed by 8 bits, a pattern 501 (FIG. 5B) obtained by multiplying each threshold value in the pattern 401 by 17(=255/15) is popularly used.
When already binarized data (e.g., a binary image, each pixel of which does not assume a value other than 0 indicating black or 255 indicating white) in place of a halftone image, periodic noise components appear in the output image. This will be explained below.
Assume that binarization is done using a pseudo random number pattern 501 shown in FIG. 5B. If the gradation values of the respective pixels of the input image are compared with the individual threshold values in the pattern 501 using:
pixel that satisfies gradation valuexe2x89xa7threshold valuexe2x86x92white
pixel that satisfies gradation value less than threshold valuexe2x86x92blackxe2x80x83xe2x80x83(i)
since gradation valuexe2x89xa7threshold value always holds for elements with a threshold value=0 in the pattern 501, the corresponding pixel of the dither image always becomes white. As a consequence, if the input image is already binarized, white isolated pixels periodically appear, as indicated by 601 in FIG. 6. Note that 601 in FIG. 6 indicates dither image blocks output when an image, all the pixels of which are black (gradation value=0) is input using the pseudo random number pattern 501. Since the upper left threshold value in the pattern 501 is 0, a pixel at that position in each output dither image block 601 is white.
On the other hand, if the gradation values of the respective pixels of the input image are compared with the individual threshold values in the pattern 501 using:
pixel that satisfies gradation value greater than threshold valuexe2x86x92white
pixel that satisfies gradation valuexe2x89xa6threshold valuexe2x86x92blackxe2x80x83xe2x80x83(ii)
since gradation valuexe2x89xa6threshold value always holds for elements with a threshold value=255 in the pattern 501, the corresponding pixel of the dither image always becomes black. As a consequence, if the input image is already binarized, black isolated pixels periodically appear, as indicated by 602 in FIG. 6. Note that 602 in FIG. 6 indicates dither image blocks output when an image, all the pixels of which are white (gradation value=255) is input using the pseudo random number pattern 501. Since the lower left threshold value in the pattern 501 is 255, a pixel at that position in each output dither image block 602 is black.
If a method of comparing an input image with a fixed threshold value (e.g., 128) is used, such problems are not posed. However, a binary image obtained from an input halftone image by such method cannot be used.
The present invention has been made in consideration of the conventional problems, and has as its object to provide an image processing apparatus, which can prevent noise, i.e., periodic appearance of white or black isolated pixels even when an already binarized image is input in binarization that normally receives a halftone image, and can obtain a dither image having quality as high as that obtained by the conventional method even when a halftone image is input.
In order to achieve the above object, an image processing apparatus of claim 1 comprises input means for inputting digital image data, pseudo random number pattern generation means for generating a pseudo random number pattern which consists of, as elements, threshold values set at substantially equal intervals without containing minimum and maximum gradation values of pixels of the input image data, and binarization means for binarizing the input image data by ordered dithering using the pseudo random number pattern.
The invention of claim 2 is directed to a storage medium which stores a binarization program for binarizing and outputting input digital image data, the binarization program comprising the input step of inputting digital image data, the pseudo random number pattern generation step of generating a pseudo random number pattern which consists of, as elements, threshold values set at substantially equal intervals without containing minimum and maximum gradation values of pixels of the input image data, and the binarization step of binarizing the input image data by ordered dithering using the pseudo random number pattern.